#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   APP_CommunicationControl_0x28_test.py
@Time    :   2025/04/03 13:31:28
@Author  :   YangLiang 
@Version :   1.0
@Contact :   yangl@genvict.com
@License :   (C)Copyright 2022-2025
@Desc    :   UDS 0x28通信控制服务测试
'''

from pytest_assume.plugin import assume
import pytest
import logging
import time
from commDriver.TS_CAN import *
import allure
import sys
sys.dont_write_bytecode = True

# region 测试数据定义
communicationControl = [
    ("28 00 01", "68 00"),          # 子功能00 + 控制类型01
    ("28 03 01", "68 03"),          # 子功能03 + 控制类型01
    ("28 00 03", "68 00"),          # 子功能00 + 控制类型03
    ("28 03 03", "68 03"),          # 子功能03 + 控制类型03
    ("28 80 01", ""),               # 子功能00 + 控制类型01
    ("28 83 01", ""),               # 子功能03 + 控制类型01
    ("28 80 03", ""),               # 子功能00 + 控制类型03
    ("28 83 03", ""),               # 子功能03 + 控制类型03
]

communicationControl_NRC7F = [
    ("28 00 01", "7F 28 7F"),
    ("28 03 01", "7F 28 7F"),
    ("28 00 03", "7F 28 7F"),    
    ("28 03 03", "7F 28 7F"),
    ("28 80 01", "7F 28 7F"),
    ("28 83 01", "7F 28 7F"),
    ("28 80 03", "7F 28 7F"),
    ("28 02 03", "7F 28 7F"),       # 7F > 12
    ("28 83 03", "7F 28 7F"),       # 7F > 12
    ("28 00 01 00", "7F 28 7F"),    # 7F > 13
    ("28", "7F 28 7F"),             # 7F > 13
    ("28 00 05", "7F 28 7F"),       # 7F > 31
    ("28 80 01 00 00", "7F 28 7F"), # 7F > 31
    ("28 83 03 00", "7F 28 7F"),    # 7F > 31 
]

communicationControl_NRC13 = [
    ("28", "7F 28 13"),             # 缺失子功能
    ("28 00", "7F 28 13"),          # 缺失控制类型
    ("28 03", "7F 28 13"),          # 缺失控制类型
    ("28 00 01 00", "7F 28 13"),    # 子功能00带多余参数
    ("28 03 03 00", "7F 28 13"),    # 子功能03带多余参数
    ("28 03 01 FF", "7F 28 13"),    # 子功能03带多余参数
    ("28 00 01 FF", "7F 28 13"),    # 子功能00带多余参数
    ("28 00 01 00 00", "7F 28 13"), # 子功能00带多余参数
    ("28 03 03 00 00", "7F 28 13"), # 子功能03带多余参数
    ("28 80", "7F 28 13"),          # 缺失控制类型
    ("28 83", "7F 28 13"),          # 缺失控制类型
    ("28 80 01 00", "7F 28 13"),    # 子功能00带多余参数
    ("28 83 03 00", "7F 28 13"),    # 子功能03带多余参数
    ("28 83 01 FF", "7F 28 13"),    # 子功能03带多余参数
    ("28 80 01 FF", "7F 28 13"),    # 子功能00带多余参数
]

communicationControl_NRC12 = [
    ("28 01 01", "7F 28 12"),       # 不支持子功能01
    ("28 02 01", "7F 28 12"),       # 不支持子功能02
    ("28 04 01", "7F 28 12"),       # 无效子功能04
    ("28 FF 01", "7F 28 12"),       # 无效子功能04
    ("28 01 03", "7F 28 12"),       # 不支持子功能01
    ("28 02 03", "7F 28 12"),       # 不支持子功能02
    ("28 04 03", "7F 28 12"),       # 无效子功能04
    ("28 FF 03", "7F 28 12"),       # 无效子功能04
    ("28 01 00", "7F 28 12"),       # 不支持子功能01
    ("28 02 00", "7F 28 12"),       # 不支持子功能02
    ("28 04 00", "7F 28 12"),       # 无效子功能04
    ("28 FF 00", "7F 28 12"),       # 无效子功能04
    ("28 81 01", "7F 28 12"),       # 不支持子功能01
    ("28 82 01", "7F 28 12"),       # 不支持子功能02
    ("28 81 03", "7F 28 12"),       # 不支持子功能01
    ("28 82 03", "7F 28 12"),       # 不支持子功能02

]

communicationControl_NRC31 = [
    ("28 00 00", "7F 28 31"),       # 不支持控制类型00
    ("28 00 02", "7F 28 31"),       # 不支持控制类型02
    ("28 00 04", "7F 28 31"),       # 无效控制类型04
    ("28 03 00", "7F 28 31"),       # 不支持控制类型00
    ("28 03 02", "7F 28 31"),       # 不支持控制类型02
    ("28 03 04", "7F 28 31"),       # 无效控制类型04
    ("28 80 00", "7F 28 31"),       # 不支持控制类型00
    ("28 80 02", "7F 28 31"),       # 不支持控制类型02
    ("28 80 04", "7F 28 31"),       # 无效控制类型04
    ("28 83 00", "7F 28 31"),       # 不支持控制类型00
    ("28 83 02", "7F 28 31"),       # 不支持控制类型02
    ("28 83 04", "7F 28 31"),       # 无效控制类型04
]

communicationControl_NRC22 = [
    ("28 00 01", "7F 28 22"),       # 车速不满足条件
    ("28 03 01", "7F 28 22"),       # 挡位不满足条件
    ("28 00 03", "7F 28 22"),       # 车速不满足条件
    ("28 03 03", "7F 28 22"),       # 挡位不满足条件
    ("28 80 03", "7F 28 22"),       # 车速不满足条件
    ("28 83 03", "7F 28 22"),       # 挡位不满足条件
    ("28 80 01", "7F 28 22"),       # 车速不满足条件
    ("28 83 01", "7F 28 22"),       # 挡位不满足条件
]

# endregion

# region 物理寻址测试
class Test_APP_CommunicationControl_Phy:
    """物理寻址模式测试"""
    @allure.severity('normal')
    @allure.title('物理寻址-扩展会话-基础功能测试')
    @allure.description('验证物理寻址扩展会话下支持子功能和控制类型的正响应')
    @pytest.mark.parametrize('req,resp', communicationControl, 
                           ids=[f"Request {req}" for req, _ in communicationControl])
    def test_CommunicationControl_Extended_Phy(self, action, Driver, req, resp):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False)

    @allure.severity('normal')
    @allure.title('物理寻址-默认会话-NRC7F测试')
    @allure.description('验证物理寻址默认会话下应响应NRC7F')
    @pytest.mark.parametrize('req,resp', communicationControl_NRC7F, 
                           ids=[f"Req:{req}" for req, _ in communicationControl_NRC7F])
    def test_CommunicationControl_NRC7F_Default_Phy(self, action, Driver, req, resp):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False)

    @allure.severity('normal')
    @allure.title('物理寻址-扩展会话-NRC13测试')
    @allure.description('验证物理寻址扩展会话下应响应NRC13')
    @pytest.mark.parametrize('req,resp', communicationControl_NRC13, 
                           ids=[f"Req:{req}" for req, _ in communicationControl_NRC13])
    def test_CommunicationControl_NRC13_Entended_Phy(self, action, Driver, req, resp):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False)

    @allure.severity('normal')
    @allure.title('物理寻址-扩展会话-NRC12测试')
    @allure.description('验证物理寻址扩展会话下应响应NRC12')
    @pytest.mark.parametrize('req,resp', communicationControl_NRC12, 
                           ids=[f"Req:{req}" for req, _ in communicationControl_NRC12])
    def test_CommunicationControl_NRC12_Entended_Phy(self, action, Driver, req, resp):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False)

    @allure.severity('normal')
    @allure.title('物理寻址-扩展会话-NRC31测试')
    @allure.description('验证物理寻址扩展会话下应响应NRC31')
    @pytest.mark.parametrize('req,resp', communicationControl_NRC31, 
                           ids=[f"Req:{req}" for req, _ in communicationControl_NRC31])
    def test_CommunicationControl_NRC31_Extended_Phy(self, action, Driver, req, resp):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False)

    @allure.severity('normal')
    @allure.title('物理寻址-扩展会话-NRC22测试')
    @allure.description('验证物理寻址扩展会话下应响应NRC22')
    @pytest.mark.parametrize('req,resp', communicationControl_NRC22, 
                           ids=[f"Req:{req}" for req, _ in communicationControl_NRC22])
    def test_CommunicationControl_NRC22_Extended_Phy(self, action, Driver, req, resp):
        iStep = 1
        # 切换到扩展会话
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 03', '50 03', 0, iStep, False)
        # 设置车速大于3kph
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        time.sleep(1)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, resp, 0, iStep, False)
        # 设置车速小于3kph
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        if str.find(req, '28 8') != -1:
            resp = ''
        else:
            resp = '68'
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, resp, 0, iStep, False)

    @allure.severity('critical')
    @allure.title('物理寻址-扩展会话-最小长度NRC13/NRC12优先级验证')
    @allure.description('验证物理寻址扩展会话下最小长度NRC响应顺序：13 > 12')
    def test_CommunicationControl_NRC13_NRC12_Priority_Entended_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 05', '7F 28 13', 3, iStep, False)
    
    @allure.severity('critical')
    @allure.title('物理寻址-扩展会话-NRC12/NRC13优先级验证')
    @allure.description('验证物理寻址扩展会话下NRC响应顺序：12 > 13')
    def test_CommunicationControl_NRC12_NRC13_Priority_Extended_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 05 01', '7F 28 12', 3, iStep, False)

    @allure.severity('critical')
    @allure.title('物理寻址-扩展会话-NRC13/NRC31优先级验证')
    @allure.description('验证物理寻址扩展会话下NRC响应顺序：13 > 31')
    def test_CommunicationControl_NRC13_NRC31_Priority_Extended_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 04 01', '7F 28 13', 3, iStep, False)
    
    @allure.severity('critical')
    @allure.title('物理寻址-扩展会话-NRC12/NRC31优先级验证')
    @allure.description('验证物理寻址扩展会话下NRC响应顺序：12 > 31')
    def test_CommunicationControl_NRC12_NRC31_Priority_Extended_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 05 04', '7F 28 12', 3, iStep, False)

    @allure.severity('critical')
    @allure.title('物理寻址-扩展会话-NRC13/NRC22优先级验证')
    @allure.description('验证物理寻址扩展会话下NRC响应顺序：13 > 22')
    def test_CommunicationControl_NRC13_NRC22_Priority_Extended_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 03', '50 03', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 01 04', '7F 28 13', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 01 04', '7F 28 13', 0, iStep, False)

    @allure.severity('critical')
    @allure.title('物理寻址-扩展会话-NRC12/NRC22优先级验证')
    @allure.description('验证物理寻址扩展会话下NRC响应顺序：12 > 22')
    def test_CommunicationControl_NRC12_NRC22_Priority_Extended_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 03', '50 03', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 05 01', '7F 28 12', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 05 01', '7F 28 12', 0, iStep, False)

    @allure.severity('critical')
    @allure.title('物理寻址-扩展会话-NRC31/NRC22优先级验证')
    @allure.description('验证物理寻址扩展会话下NRC响应顺序：31 > 22')
    def test_CommunicationControl_NRC31_NRC22_Priority_Extended_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 03', '50 03', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 04', '7F 28 31', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 04', '7F 28 31', 0, iStep, False)

    @allure.severity('critical')
    @allure.title('物理寻址-默认会话-NRC7F/NRC22优先级验证')
    @allure.description('验证物理寻址默认会话下NRC响应顺序：7F > 22')
    def test_CommunicationControl_NRC7F_NRC22_Priority_Default_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 01', '50 01', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 01', '7F 28 7F', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 01', '7F 28 7F', 0, iStep, False)

    @allure.severity('critical')
    @allure.title('物理寻址-扩展会话-禁止常规通信报文功能')
    @allure.description('验证物理寻址扩展会话下禁止常规通信报文功能')
    def test_CommunicationControl_NCM_Extended_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 03', '50 03', 0, iStep, False)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 03 01', '68 03', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 01', '68 00', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 01', '68 00', 0, iStep, False)

    @allure.severity('critical')
    @allure.title('物理寻址-扩展会话-禁止所有通信报文功能')
    @allure.description('验证物理寻址扩展会话下禁止所有通信报文功能')
    def test_CommunicationControl_NM_NCM_Extended_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 03', '50 03', 0, iStep, False)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 03 03', '68 03', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 03', '68 00', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 03', '68 00', 0, iStep, False)

    
    # endregion
# endregion

# region 功能寻址测试
class Test_APP_CommunicationControl_Func:
    """功能寻址模式测试"""
    
    @allure.severity('normal')
    @allure.title('功能寻址-扩展会话-基础功能测试')
    @allure.description('验证功能寻址扩展会话下支持子功能和控制类型的正响应')
    @pytest.mark.parametrize('req,resp', communicationControl,
                           ids=[f"Request {req}" for req, _ in communicationControl])
    def test_CommunicationControl_Extended_Func(self, action, Driver, req, resp):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun')

    @allure.severity('normal')
    @allure.title('功能寻址-默认会话-NRC7F测试')
    @allure.description('验证功能寻址默认会话下应响应NRC7F')
    @pytest.mark.parametrize('req,resp', communicationControl_NRC7F,
                           ids=[f"Req:{req}" for req, _ in communicationControl_NRC7F])
    def test_CommunicationControl_NRC7F_Default_Func(self, action, Driver, req, resp):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, '', 1, iStep, False, 'UDSFun')

    @allure.severity('normal')
    @allure.title('功能寻址-扩展会话-NRC13测试')
    @allure.description('验证功能寻址扩展会话下应响应NRC13')
    @pytest.mark.parametrize('req,resp', communicationControl_NRC13,
                           ids=[f"Req:{req}" for req, _ in communicationControl_NRC13])
    def test_CommunicationControl_NRC13_Extended_Func(self, action, Driver, req, resp):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun')

    @allure.severity('normal')
    @allure.title('功能寻址-扩展会话-NRC12测试')
    @allure.description('验证功能寻址扩展会话下应响应NRC12')
    @pytest.mark.parametrize('req,resp', communicationControl_NRC12,
                           ids=[f"Req:{req}" for req, _ in communicationControl_NRC12])
    def test_CommunicationControl_NRC12_Extended_Func(self, action, Driver, req, resp):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, '', 3, iStep, False, 'UDSFun')

    @allure.severity('normal')
    @allure.title('功能寻址-扩展会话-NRC31测试')
    @allure.description('验证功能寻址扩展会话下应响应NRC31')
    @pytest.mark.parametrize('req,resp', communicationControl_NRC31,
                           ids=[f"Req:{req}" for req, _ in communicationControl_NRC31])
    def test_CommunicationControl_NRC31_Extended_Func(self, action, Driver, req, resp):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, '', 3, iStep, False, 'UDSFun')

    @allure.severity('normal')
    @allure.title('功能寻址-扩展会话-NRC22测试')
    @allure.description('验证功能寻址扩展会话下NRC22测试')
    @pytest.mark.parametrize('req,resp', communicationControl_NRC22,
                           ids=[f"Req:{req}" for req, _ in communicationControl_NRC22])
    def test_CommunicationControl_NRC22_Extended_Func(self, action, Driver, req, resp):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 03', '50 03', 0, iStep, False, 'UDSFun')
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        time.sleep(1)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, resp, 0, iStep, False, 'UDSFun')
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        if str.find(req, '28 8')!= -1:
            resp = ''
        else:
            resp = '68'
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, req, resp, 0, iStep, False, 'UDSFun')

    # 优先级验证测试组
    @allure.severity('critical')
    @allure.title('功能寻址-扩展会话-最小长度NRC13/NRC12优先级验证')
    @allure.description('验证功能寻址扩展会话下最小长度NRC响应顺序：13 > 12')
    def test_CommunicationControl_NRC13_NRC12_Priority_Extended_Func(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 05', '7F 28 13', 3, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('功能寻址-扩展会话-NRC12/NRC13优先级验证')
    @allure.description('验证功能寻址扩展会话下NRC响应顺序：12 > 13')
    def test_CommunicationControl_NRC12_NRC13_Priority_Extended_Func(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 05 01', '', 3, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('功能寻址-扩展会话-NRC13/NRC31优先级验证')
    @allure.description('验证功能寻址扩展会话下NRC响应顺序：13 > 31')
    def test_CommunicationControl_NRC13_NRC31_Priority_Extended_Func(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 04 01', '7F 28 13', 3, iStep, False, 'UDSFun')
    
    @allure.severity('critical')
    @allure.title('功能寻址-扩展会话-NRC12/NRC31优先级验证')
    @allure.description('验证功能寻址扩展会话下NRC响应顺序：12 > 31')
    def test_CommunicationControl_NRC12_NRC31_Priority_Extended_Func(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 05 04', '', 3, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('功能寻址-扩展会话-NRC13/NRC22优先级验证')
    @allure.description('验证功能寻址扩展会话下NRC响应顺序：13 > 22')
    def test_CommunicationControl_NRC13_NRC22_Priority_Extended_Func(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 03', '50 03', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 01 04', '7F 28 13', 0, iStep, False, 'UDSFun')
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 01 04', '7F 28 13', 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('功能寻址-扩展会话-NRC12/NRC22优先级验证')
    @allure.description('验证功能寻址扩展会话下NRC响应顺序：12 > 22')
    def test_CommunicationControl_NRC12_NRC22_Priority_Extended_Func(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 03', '50 03', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 05 01', '', 0, iStep, False, 'UDSFun')
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 05 01', '', 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('功能寻址-扩展会话-NRC31/NRC22优先级验证')
    @allure.description('验证功能寻址扩展会话下NRC响应顺序：31 > 22')
    def test_CommunicationControl_NRC31_NRC22_Priority_Extended_Func(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 03', '50 03', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 04', '', 0, iStep, False, 'UDSFun')
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 04', '', 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('功能寻址-默认会话-NRC7F/NRC22优先级验证')
    @allure.description('验证功能寻址默认会话下NRC响应顺序：7F > 22')
    def test_CommunicationControl_NRC7F_NRC22_Priority_Default_Func(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 01', '50 01', 0, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 01', '', 0, iStep, False, 'UDSFun')
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 01', '', 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('功能寻址-扩展会话-禁止常规通信报文功能')
    @allure.description('验证功能寻址扩展会话下禁止常规通信报文功能')
    def test_CommunicationControl_NCM_Extended_Func(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 03', '50 03', 0, iStep, False)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 03 01', '68 03', 0, iStep, False, 'UDSFun')
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 01', '68 00', 0, iStep, False, 'UDSFun')
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 01', '68 00', 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('功能寻址-扩展会话-禁止所有通信报文功能')
    @allure.description('验证功能寻址扩展会话下禁止所有通信报文功能')
    def test_CommunicationControl_NM_NCM_Extended_Func(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '10 03', '50 03', 0, iStep, False)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 03 03', '68 03', 0, iStep, False, 'UDSFun')
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 5)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 03', '68 00', 0, iStep, False, 'UDSFun')
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, '28 00 03', '68 00', 0, iStep, False, 'UDSFun')
# endregion